package com.sg.service.biz.component.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.component.req.GenerateNameNaturalDayComReqDto;
import com.sg.dto.biz.component.res.GenerateNameNaturalDayComRespDto;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class CycleTypeServiceImpl
        implements com.wicket.okrcomponent.biz.service.CycleTypeService {

    @Resource
    private RedisUtil redisUtil;
    //@Resource
    //private MCustomFields3Service mCustomFields3Service;
    @Resource
    private NbCycleType nbCycleType;

    /**
     * D2生成自然日名称(公共)[5382]
     * gen by moon at 2/27/2023, 3:31:16 PM
     */
    @Trace(operationName = "D2生成自然日名称(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public GenerateNameNaturalDayComRespDto generateNameNaturalDayCom(GenerateNameNaturalDayComReqDto reqDto) {


        GenerateNameNaturalDayComRespDto analyzeAndGenerateDateRes_1 = null;
//步骤0: M2生成自然日名称（特殊方法） - generateNameNaturalDay
        //ModelCode: analyzeAndGenerateDate
        GenerateNameNaturalDayComRespDto analyzeAndGenerateDateRes = null;
        GenerateNameNaturalDayComReqDto analyzeAndGenerateDateReq = new GenerateNameNaturalDayComReqDto();
        if (reqDto != null) {
            analyzeAndGenerateDateReq.setComTimeField(reqDto.getComTimeField());//SimpleFieldAssign//sourceId:483298_1
            analyzeAndGenerateDateReq.setComNumField(reqDto.getComNumField());//SimpleFieldAssign//sourceId:483299_1
        }
  
    /*M2生成自然日名称（特殊方法）[5381]  入参字段时间点，根据入参的格式1或者2，生成不同格式的自然日名称
格式1：****年**月**日  例子，2022年2月12日、2022年12月8日
格式2：****。** 。**   例子，2022.02.12  、2022.12.08 */
        Assert.isNull(analyzeAndGenerateDateReq.getComTimeField(), "D2生成自然日名称(公共)-M2生成自然日名称（特殊方法）-通用时间字段不能为空", false);
        Assert.isNull(analyzeAndGenerateDateReq.getComNumField(), "D2生成自然日名称(公共)-M2生成自然日名称（特殊方法）-通用数值字段（整数型）不能为空", false);
        analyzeAndGenerateDateRes = nbCycleType.generateNameNaturalDayCom(analyzeAndGenerateDateReq);


        analyzeAndGenerateDateRes_1 = analyzeAndGenerateDateRes;

        GenerateNameNaturalDayComRespDto retData = new GenerateNameNaturalDayComRespDto();
        if (analyzeAndGenerateDateRes_1 != null) {
            retData.setCustomField(analyzeAndGenerateDateRes_1.getCustomField());//SimpleFieldAssign//sourceId:483372_1
        }


        return retData;
    }
    //
}
